package models

import (
	"errors"

	"github.com/astaxie/beego/orm"
)

type SysParams struct {
	Id     string `orm:"column(id);pk"`
	OrgId  string `orm:"column(org_id);null"`
	DeptId string `orm:"column(dept_id);null"`
	Key    string `orm:"column(key);null"`
	Value  string `orm:"column(value);null"`
	Status int    `orm:"column(status);null"`
}

func (t *SysParams) TableName() string {
	return "sys_params"
}

func init() {
	orm.RegisterModel(new(SysParams))
}

func GetParamsById(id string) (SysParams, error) {
	o := orm.NewOrm()
	var param SysParams
	if err := o.QueryTable(new(SysParams)).Filter("id", id).One(&param); err == nil {
		return param, nil
	} else {
		return param, err
	}
}

func GetParamsPhone() (*SysParams, error) {
	o := orm.NewOrm()
	err := errors.New("")
	v := &SysParams{Id: "09046209-1967-4ac6-a284-b7ff9690d0df"}
	if err = o.Read(v); err == nil {
		return v, nil
	}
	return nil, err
}
